# !/usr/bin/env python
# -*- coding: utf-8 -*-

# @ author = 'zoushunli'
# @ author_email = '409358374@qq.com'
# 中文字符的正则表达式:[\u4e00-\u9fa5]

# 防止因https证书问题报错
# requests.packages.urllib3.disable_warnings()
# 将中文转化成%xxx, 进行编码   urllib.parse.quote(query_string)
# 将%xxx转化成指定字符, 进行解码   urllib.parse.unquote(query_string)
# 将字典拼接成query_string实现编码功能,   urllib.parse.unlencode(query_string)
#requests 用get 时  params 可以放字典数据
#         用post 时  data 可以放字典数据
# requests.cookies
# r = self.requests_get(url, headers=self.headers, timeout=10)
# 获取请求头
# print(r.request.headers)
# 获取响应头
# print(r.headers)
# 获取状态码
# r.status_code
# 获取请求对象的cookie
# print(r.request._cookies)
# print('=='*30)
# 获取响应的cookie
# print(r.cookies)
# https://www.bilibili.com/video/BV18J411t7Qy?p=9 第九p 介绍mongoDB
# 创建用户, 给予root权限
# db.createUser({user: "admin", pwd: "zsl1994", roles: ["root"]})
# 登入已创建的用户
# db.auth('username','pwd')
# 登入成功后 才可以继续创建
# db.createUser({user: 'name2', pwd: '123456', roles: ['test']})
# 查看所有用户
# use admin
# show user(root 权限)
# 删除用户
# db.dropUser('用户名')
# Pyinstaller -F -i xx.ico setup.py
# 分块：定义一个函数以按照这个大小切割列表
from math import ceil
def chunk(lst, size):
    return list(map(lambda x: lst[x * size: x * size + size], list(range(0, ceil(len(lst) / size)))))
user_agent = [
'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36',
'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:76.0) Gecko/20100101 Firefox/76.0'
]


aa = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k']
dd = chunk(aa, 3)

# 将两个列表转成字典
def to_dict(keys, values):
    return dict(zip(keys, values))
# 合并两字典
def merge_dict(a, b):
    c = a.copy()
    c.update(b)
    return c
def merge_dict(a, b):

    return {**a, **b}

url = ''
headers = {
    "Host": url,
    "User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:77.0) Gecko/20100101 Firefox/77.0",
    "Accept": "text/css/javascript, json/application*/*;q=0.1",
    "Accept-Language": "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2",
    # "Accept-Encoding": "gzip, deflate, br",  # 把数据在服务端压缩后发送给客户端，一般情况下屏蔽掉
    "Connection": "keep-alive"

}

